package edu.gdcc.linearList.stack;

import java.util.ArrayList;
import java.util.Stack;

import com.sun.xml.internal.bind.v2.schemagen.xmlschema.List;

/**
 * ADT Stack:升级版的Stack
 * method:push,pop,currentCapacity(当前栈内元素个数),isEmpty,isFull,peek(栈顶元素)
 * @author Izzy.X
 * @version 2017-01-08 11:16:56 1.2
 *
 */
public class StackXUpgrade {
	private int size;
	private Object[] stackArr;
	private int top;
	//constructor
	public StackXUpgrade (int size) {
		this.size = size;
		this.stackArr = new Object[size];
		this.top = -1;
	}
	
	//method
	public void push(Object o){
		stackArr[++top] = o;
	}
	public Object pop(){
		return stackArr[top--];
	}
	public int currentCapacity(){
		return top+1;
	}
	public boolean isEmpty(){
		return top == -1;
	}
	public boolean isFull(){
		return (top == size - 1);
	}
	public Object peek(){
		return stackArr[top]; 
	}
}
